﻿using MediatR;
using SheepStorage.API.Application.Command.BodySizeCommand;
using SheepStorage.API.Application.Command.SheepConditionCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.SheepConditionHandler
{
    public class SheepConditionCreateHandler : IRequestHandler<SheepConditionCreateCommand, Results<int>>
    {

        private readonly ISheepConditionService service;

        public SheepConditionCreateHandler(ISheepConditionService service)
        {
            this.service = service;
        }
        public async Task<Results<int>> Handle(SheepConditionCreateCommand request, CancellationToken cancellationToken)
        {
            var entity = new SheepCondition
            {
                SheepConditionId=request.SheepConditionId,
                OverBit=request.OverBit,
                SheepConditionSex=request.SheepConditionSex==1?true:false,
                SheepType=request.SheepType,
                CheckDate=request.CheckDate,
                TeethTobite=request.TeethTobite,
                ConditionHair=request.ConditionHair,
                ConditionStain=request.ConditionStain,
                ShoeColor=request.ShoeColor,
                MouthColor=request.MouthColor,
                ConditionCorner=request.ConditionCorner,
                ConditionFat=request.ConditionFat,

                AddTime = DateTime.Now,
                AddName = "侯佳",
                IsDel = 0,
            };
            var list = await service.AddSheepCondition(entity);
            return Results<int>.DataResult(list);
        }
    }
}
